package br.edu.ufcg.dsc.actions;

import org.apache.struts2.config.ParentPackage;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
import org.apache.struts2.dispatcher.ServletDispatcherResult;
import org.apache.struts2.dispatcher.ServletRedirectResult;

import br.edu.ufcg.dsc.domain.User;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

@ParentPackage(value = "myPackage")
@Results(value = {
		@Result(name = "input", type = ServletDispatcherResult.class, value = "/jsp/user/login.jsp"),
		@Result(name = "success", type = ServletRedirectResult.class, value = "/index.action") })
public class IndexLoginAction extends ActionSupport {

	private static final long serialVersionUID = 8723969851239730089L;

	@Override
	public String execute() throws Exception {
		User user = (User) ActionContext.getContext().getSession().get("user");

		if (user == null)
			return INPUT;
		else
			return SUCCESS;
	}

}
